<script setup lang="ts">
import { type typeCalss } from '@/apis/video'
import { type Ref, ref, watch } from 'vue'

const props = defineProps(['classList', 'typeId'])

let itPickClass: Ref<typeCalss>

function resetItPick() {
  for (let i in props.classList) {
    if (props.classList[i].type_id == props.typeId) {
      itPickClass = ref(props.classList[i])
      break
    }
  }
}

watch(
  () => props.classList,
  () => {
    resetItPick()
  },
  { immediate: true }
)

watch(
  () => props.typeId,
  () => {
    resetItPick()
  }
)
</script>

<template>
  <div>
    <div class="box">
      <router-link :to="`/home/${item.type_id}`" v-for="item in props.classList" :key="item.type_id">
        <div class="leftPick" :class="{ 'leftPick-chouse': itPickClass.type_id == item.type_id }">
          <div>{{ item.type_name }}</div>
        </div>
      </router-link>
    </div>
  </div>
</template>

<style scoped lang="less">
.box {
  width: 140px;
  direction: ltr;
  padding-left: 30px;
  user-select: none;
  -webkit-user-select: none;
}
.leftPick {
  cursor: pointer;
  height: 50px;
  font-size: 15px;
  white-space: nowrap;
  font-weight: 600;
  display: flex;
  align-items: center;
  * {
    color: rgba(255, 255, 255, 0.7);
  }

  &:hover,
  &-chouse {
    font-size: 20px;
    transition: 0.1s;
    font-weight: 800;
    * {
      color: #fff;
    }
  }
}

.router-link-active {
  text-decoration: none;
}

a {
  text-decoration: none;
}
</style>
